const MessageStore = {
  namespace: true,
  state: {
    // 当前拿到的所有信息
    allMessage: [],
    // 当前留言信息一些配置
    
  },
  mutations: {
    addMessage(state, newMessage) {
      const d = new Date();
      const year = d.getFullYear();
      const month = d.getMonth() + 1;
      const date = d.getDate();
      const hour = d.getHours();
      const min = d.getMinutes();
      const sec = d.getSeconds();
      state.allMessage.push({
        content: newMessage,
        timestamp: `${year}-${month}-${date}  ${hour}:${min}:${sec}`,
      });
    },
    deleteMessage(state, index) {
      state.allMessage.splice(index, 1);
    },
  },
};
export default MessageStore;
